package life.system.product.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import life.system.product.entity.SkuInfoDescEntity;
import life.system.product.service.SkuInfoDescService;
import life.system.common.utils.PageUtils;
import life.system.common.utils.R;



@RestController
@RequestMapping("product/skuinfodesc")
public class SkuInfoDescController {
    @Autowired
    private SkuInfoDescService skuInfoDescService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = skuInfoDescService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{skuId}")
    public R info(@PathVariable("skuId") Integer skuId){
		SkuInfoDescEntity skuInfoDesc = skuInfoDescService.getById(skuId);

        return R.ok().put("skuInfoDesc", skuInfoDesc);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody SkuInfoDescEntity skuInfoDesc){
		skuInfoDescService.save(skuInfoDesc);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody SkuInfoDescEntity skuInfoDesc){
		skuInfoDescService.updateById(skuInfoDesc);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] skuIds){
		skuInfoDescService.removeByIds(Arrays.asList(skuIds));

        return R.ok();
    }

}
